//
//  UILabel+RxExtection.swift
//  YKSwiftRxExtection
//
//  Created by edward on 2022/1/10.
//

import UIKit
import RxSwift


extension Reactive where Base: UILabel {
    
    public func text() -> Binder<String?> {
        Binder(self.base) { label, text in
            label.text = text
        }
    }
    
    public func textColor() -> Binder<UIColor> {
        Binder(self.base) { label, color in
            label.textColor = color
        }
    }
    
    public func fontSize(_ weight: UIFont.Weight = .regular) -> Binder<CGFloat?> {
        Binder(self.base) { label, size in
            if let s = size {
                label.font = UIFont.systemFont(ofSize: s, weight: weight)
            }
        }
    }
    
    public func attributedText() -> Binder<NSAttributedString?> {
        Binder(self.base) { label, attributedText in
            label.attributedText = attributedText
        }
    }
}
